/**
 * Copyright (C) 2012 The SkyTvOS Project
 * <p/>
 * Version     Date           Author
 * ─────────────────────────────────────
 * 2014-8-20         luwei
 */

package com.tianci.appstore.ui.mainpage;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.view.Gravity;
import android.view.View;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
import android.widget.TextView;

import com.coocaa.x.app.framework.app.LiteAppApplication;
import com.tianci.appstore.R;
import com.tianci.appstore.ui.SkinManager;
import com.tianci.appstore.ui.data.SkyAppBaseData;
import com.tianci.appstore.ui.widget.SkyBaseItemView;
import com.tianci.appstore.ui.widget.TipToast;
import com.tianci.appstore.utils.SkyConstants;

public class ContactBlock extends SkyBaseItemView {
    private ImageView mWechatQRCode = null;

    public ContactBlock(Context context) {
        super(context);
    }

    @Override
    protected void createView() {
        addWechatCode();
        addPointView();
        // addJustAndroid();
        addQQPointView();
    }

    private void addWechatCode() {
        mWechatQRCode = new ImageView(mContext);
        mWechatQRCode.setScaleType(ScaleType.CENTER_CROP);
        SkinManager.setBackground(mWechatQRCode, R.drawable.mobile_qr_code);
        LayoutParams iconParams = new LayoutParams(SkyConstants.Div(215), SkyConstants.Div(215),
                Gravity.CENTER_HORIZONTAL);
        iconParams.topMargin = SkyConstants.shadowWidth + SkyConstants.Div(35);
        this.addView(mWechatQRCode, iconParams);
    }

    private void addPointView() {
        TextView textView = new TextView(mContext);
        textView.setGravity(Gravity.CENTER);
        textView.setSelected(false);
        textView.setTextSize(SkyConstants.Dpi(32));
        textView.setTextColor(Color.WHITE);
        textView.setText(R.string.scan_wechat_qrcode);
        LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL);
        params.topMargin = SkyConstants.Div(310);
        textView.setLayoutParams(params);
        addView(textView);
    }

    private void addJustAndroid() {
        TextView textView = new TextView(mContext);
        textView.setGravity(Gravity.CENTER);
        textView.setSelected(false);
        textView.setTextSize(SkyConstants.Dpi(20));
        textView.setTextColor(Color.WHITE);
        textView.setText(R.string.just_support_android);
        LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL);
        params.topMargin = SkyConstants.Div(410);
        textView.setLayoutParams(params);
        addView(textView);
    }

    private void addQQPointView() {
        TextView textView = new TextView(mContext);
        textView.setSelected(false);
        textView.setTextSize(SkyConstants.Dpi(32));
        textView.setTextColor(Color.WHITE);
        textView.setPadding(SkyConstants.Div(25), 0, 0, 0);
        if (LiteAppApplication.isMarketChannel() || LiteAppApplication.isCommonChannel()) {
            textView.setText(R.string.market_official_website);
        } else {
            textView.setText(R.string.official_website);
        }
        LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT, Gravity.BOTTOM);
        params.bottomMargin = SkyConstants.Div(30) + SkyConstants.shadowWidth;
        textView.setLayoutParams(params);
        addView(textView);
    }

    @Override
    public void update(SkyAppBaseData data) {
        // TODO Auto-generated method stub

    }

    @Override
    protected void refreshImage(String url, Bitmap result) {
        // TODO Auto-generated method stub

    }

    @Override
    public void onClick(View v) {
        TipToast.getInstance(mContext).showTipToast(
                getResources().getString(R.string.scan_more_wonderful));
        super.onClick(v);
    }

    @Override
    public void destory() {
        // TODO Auto-generated method stub

    }
}
